package com.xiaoxiong.bean;

public class ScheduleCourseData {
	private String courseName;// 课程名
	private String time;// 上课时间
	private int week;// 星期几上课
	private String teacher;// 老师名字
	private String room;// 教室
	private int startTime;// 第几节
	private int color;// 颜色
	private int[] weeks = new int[20];// 哪几周要上
	private int intweeks = 0;// 有多少节课
	private String Stringweeks;// 传进来的(那几周要上，字符串)
	private int id;

	public ScheduleCourseData(String courseName, String time, int week, String teacher,
			String room, int startTime, int color, String Stringweeks, int id) {
		super();
		this.courseName = courseName;
		this.time = time;
		this.week = week;
		this.teacher = teacher;
		this.room = room;
		this.startTime = startTime;
		this.color = color;
		this.Stringweeks = Stringweeks;
		this.id = id;
		dealWeeksData();
	}

	public void dealWeeksData() {
		int start = 0;
		int position = 0;
		for (int i = 0; i < Stringweeks.length(); ++i) {
			char c = Stringweeks.charAt(i);
			if (c >= '0' && c <= '9') {
				if (position == 0) {
					weeks[start] = (c - 48);
					position = 1;
				} else {
					weeks[start] = weeks[start] * 10 + (c - 48);
				}
				intweeks = start + 1;
			} else {
				position = 0;
				start++;
			}
		}
	}

	public boolean isHaveThisWeek(int week) {
		for (int i = 0; i < intweeks; ++i) {
			if (weeks[i] == week) {
				return true;
			}
		}
		return false;
	}

	public String getCourseName() {
		return courseName;
	}

	public String getTime() {
		return time;
	}

	public int getWeek() {
		return week;
	}

	public String getTeacher() {
		return teacher;
	}

	public String getRoom() {
		return room;
	}

	public int getStartTime() {
		return startTime;
	}

	public int getColor() {
		return color;
	}

	public String getStringweeks() {
		return Stringweeks;
	}

	public int getId() {
		return id;
	}
}
